<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        img{
            /*初始样式*/
            width: 50%;

            /*响应样式
            position: absolute;
            z-index: 999;
            width: 100%;

            margin: 50% 0;*/

        }
    </style>
</head>
<body>
    <span>带argument参数</span>
    <br>
    <img onclick="f1(1)" id="img1" class="offview" src="https://img0.baidu.com/it/u=741268616,1401664941&fm=253&fmt=auto&app=138&f=JPEG?w=748&h=500" alt="">
    <br>
    <span>不带argument参数</span>
    <br>
    <!-- --><img onclick="f1(2)" id="img2" src="https://img1.baidu.com/it/u=3251825469,863101163&fm=253&fmt=auto&app=138&f=JPEG?w=687&h=500" alt="">
    
        <script> 
        
        function f1(i){
            var imgi = 'img'+i
            if(document.body.getAttribute("view")=='on'){
                console.log('该关闭图片了')
                document.body.setAttribute('view','off')
                document.getElementById(imgi).style.position=''
                document.getElementById(imgi).style.zIndex=''
                document.getElementById(imgi).style.width='50%'
                document.getElementById(imgi).style.margin=''
            }else{
                    document.body.setAttribute('view','on')
                    document.getElementById(imgi).style.position='absolute'
                    document.getElementById(imgi).style.zIndex='999'
                    document.getElementById(imgi).style.width='100%'
                    document.getElementById(imgi).style.margin='50% 0'
            } 
        }
        
    </script>
    <script>
       
    </script>
</body>
</html>
